
import java.util.HashMap;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author Marc-Henri
 */
public class GameManager {

    private long centipedeCounter;
    private HashMap<Long, Centipede> centipedeMap;
    private int gameLevel;
    private int score;
    private int nbOfLifes;

    private static class CentipedeManagerHolder {

        private final static GameManager instance = new GameManager();
    }

    /**
     * Return the instance of the Centipede manager.
     * @return GameManager
     */
    public static GameManager getInstance() {
        return CentipedeManagerHolder.instance;
    }

    public Centipede getCentipede(long ID) {
        return centipedeMap.get(ID);
    }

    public Centipede CreateCentipede() {
        centipedeCounter++;
        Centipede ncp = new Centipede();
        ncp.setCentipedeId(centipedeCounter);
        centipedeMap.put(centipedeCounter, ncp);

        return ncp;
    }

    public void DeleteCentipede(long ID) {
        centipedeMap.remove(ID);
    }

    public int getNumberOfCentipede() {
        return centipedeMap.size();
    }

    public int getGameLevel() {
        return gameLevel;
    }

    public void setGameLevel(int gameLevel) {
        this.gameLevel = gameLevel;
    }

    public int getNbOfLifes() {
        return nbOfLifes;
    }

    public void setNbOfLifes(int nbOfLifes) {
        this.nbOfLifes = nbOfLifes;
    }

    public int getScore() {
        return score;
    }

    public void setScore(int score) {
        this.score = score;
    }

    public void incScore(int s) {
        score += s;
    }

    public void clear() {
        centipedeCounter = 0;
        centipedeMap.clear();
    }

    private GameManager() {
        centipedeCounter = 0;
        score = 0;
        nbOfLifes = 0;
        centipedeMap = new HashMap<Long, Centipede>();
    }
}
